<?php
/**
 * Smarty shared plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Function: smarty_insert_module<br>
 * Purpose:  calls to separate module and insert generated content in template
 * @author   David Aleksanyan
 * @param $params
 * 			module
 * 			action
 * @return string
 */
function smarty_insert_module($params, &$smarty)
{
    $getParams = array();
    $module= $params['module'];
    $action = $params['action'];
    $filename = MODULES_DIR.$module."/".$action."Action.php";
    $class = $action."Action";

    if(!file_exists($filename))
    {
        $filename = MODULES_DIR."/error/errorAction.php";
        $class = "errorAction";
    }
    require_once($filename);
    $actionClass = new $class($smarty);
    
    foreach ($_GET as $key=>$item)
    {
        $getParams[$key] = $item;
    }
    foreach ($params as $key=>$item)
    {
        if($key == "module" || $key == "action" )
        {
            continue;
        }
        $getParams[$key] = $item;
    }
    
    return $actionClass->run($getParams,$_POST,VS_PLUGIN);
}

?>
